<template>
	<view class="messagePage myBackground">
		<view v-if="breakdownData.length > 0" class="content pl15 pr15">
			<scroll-view scroll-y class="h100p w100p">
				<view>
					<view class="mb15" v-for="(item,index) in breakdownData" :key="index">
						<view class="content_item p15 boxSizing">
							<view class="itemName pb15">
								<view class="d-flex a-center">
									<view class="line mr5"></view>
									<view>{{item.deviceName}}</view>
								</view>
							</view>
							<view class="my_flex_sb mb15">
								<view class="rowName">故障位置:</view>
								<view class="rowValue">{{item.deviceLocation}}</view>
							</view>
							<view class="my_flex_sb mb15">
								<view class="rowName">故障名称:</view>
								<view class="rowValue font_red">{{item.gzName}}</view>
							</view>
							<view class="my_flex_sb mb15">
								<view class="rowName">故障时间:</view>
								<view class="rowValue">{{item.gzTime}}</view>
							</view>
						</view>
					</view>
				</view>
				<view style="height: 10rpx;"></view>
			</scroll-view>
		</view>

		<view v-else class="w100p d-flex-center" style="height: calc(100% - 60px);">
			<noValue></noValue>
		</view>

		<!-- <tab-bar-view :tabCode="'1'"></tab-bar-view> -->
	</view>
</template>

<script>
	import {
		queryThreeBuildOneFloorSafeByAppReport
	} from "@/api/dormBuilding/threeBuildOneFloor.js"
	import {
		queryThreeBuildTwoFloorSafeByAppReport
	} from "@/api/dormBuilding/threeBuildTwoFloor.js"
	import {
		queryThreeBuildThreeFloorSafeByAppReport
	} from "@/api/dormBuilding/threeBuildThreeFloor.js"
	import {
		queryThreeBuildFourFloorSafeByAppReport
	} from "@/api/dormBuilding/threeBuildFourFloor.js"
	import {
		queryThreeBuildFiveFloorSafeByAppReport
	} from "@/api/dormBuilding/threeBuildFiveFloor.js"

	import {
		querytwoBuildOneFloorSafeByAppReport
	} from "@/api/dormBuilding/twoBuildOneFloor.js"
	import {
		querytwoBuildTwoFloorSafeByAppReport
	} from "@/api/dormBuilding/twoBuildTwoFloor.js"
	import {
		querytwoBuildThreeFloorSafeByAppReport
	} from "@/api/dormBuilding/twoBuildThreeFloor.js"
	import {
		querytwoBuildFourFloorSafeByAppReport
	} from "@/api/dormBuilding/twoBuildFourFloor.js"
	import {
		querytwoBuildFiveFloorSafeByAppReport
	} from "@/api/dormBuilding/twoBuildFiveFloor.js"

	import {
		queryoneBuildOneFloorSafeByAppReport
	} from "@/api/dormBuilding/oneBuildOneFloor.js"
	import {
		queryoneBuildTwoFloorSafeByAppReport
	} from "@/api/dormBuilding/oneBuildTwoFloor.js"
	import {
		queryoneBuildThreeFloorSafeByAppReport
	} from "@/api/dormBuilding/oneBuildThreeFloor.js"
	import {
		queryoneBuildFourFloorSafeByAppReport
	} from "@/api/dormBuilding/oneBuildFourFloor.js"
	import {
		queryoneBuildFiveFloorSafeByAppReport
	} from "@/api/dormBuilding/oneBuildFiveFloor.js"

	import {
		queryOneFloorOneSafeByAppReport
	} from "@/api/electrician/oneBulid.js"
	import {
		queryTwoFloorOneSafeByAppReport
	} from "@/api/electrician/twoBulid.js"
	import {
		queryThreeFloorOneSafeByAppReport
	} from "@/api/electrician/threeBulid.js"
	export default {
		data() {
			return {
				activeMenu: "",
				timeout: [],
				breakdownData: []
			};
		},
		onLoad(query) {
			this.activeMenu = query.activeMenu
		},
		onShow() {
			this.switchShowPage(this.activeMenu)

			this.setupTimer()
		},
		onReady() {
			// 隐藏导航栏
			uni.hideTabBar({});
		},
		onUnload() {
			this.clearTimer()
		},
		methods: {
			// 设置定时器
			setupTimer() {
				let _this = this;
				_this.timeout[0] = setInterval(() => {
					_this.switchShowPage(this.activeMenu)
				}, 15000);
			},
			// 清除定时器
			clearTimer() {
				let _this = this;
				if (_this.timeout.length > 0) {
					_this.timeout.forEach(item => {
						clearInterval(item);
					})
				}
			},

			switchShowPage(data) {
				const _this = this
				switch (data) {
					case '3-1':
						_this.queryThreeBuildOneFloorSafeByAppReport()
						break;
					case '3-2':
						_this.queryThreeBuildTwoFloorSafeByAppReport()
						break;
					case '3-3':
						_this.queryThreeBuildThreeFloorSafeByAppReport()
						break;
					case '3-4':
						_this.queryThreeBuildFourFloorSafeByAppReport()
						break;
					case '3-5':
						_this.queryThreeBuildFiveFloorSafeByAppReport()
						break;
					case '2-1':
						_this.querytwoBuildOneFloorSafeByAppReport()
						break;
					case '2-2':
						_this.querytwoBuildTwoFloorSafeByAppReport()
						break;
					case '2-3':
						_this.querytwoBuildThreeFloorSafeByAppReport()
						break;
					case '2-4':
						_this.querytwoBuildFourFloorSafeByAppReport()
						break;
					case '2-5':
						_this.querytwoBuildFiveFloorSafeByAppReport()
						break;
					case '1-1':
						_this.queryoneBuildOneFloorSafeByAppReport()
						break;
					case '1-2':
						_this.queryoneBuildTwoFloorSafeByAppReport()
						break;
					case '1-3':
						_this.queryoneBuildThreeFloorSafeByAppReport()
						break;
					case '1-4':
						_this.queryoneBuildFourFloorSafeByAppReport()
						break;
					case '1-5':
						_this.queryoneBuildFiveFloorSafeByAppReport()
						break;
					case 'dg-1':
						_this.queryOneFloorOneSafeByAppReport()
						break;
					case 'dg-2':
						_this.queryTwoFloorOneSafeByAppReport()
						break;
					case 'dg-3':
						_this.queryThreeFloorOneSafeByAppReport()
						break;
					default:
						// 如果 expression 不匹配任何 case 值，则执行 default 子句中的代码块  
						break;
				}
			},

			async queryThreeBuildOneFloorSafeByAppReport() {
				await queryThreeBuildOneFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryThreeBuildTwoFloorSafeByAppReport() {
				await queryThreeBuildTwoFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryThreeBuildThreeFloorSafeByAppReport() {
				await queryThreeBuildThreeFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryThreeBuildFourFloorSafeByAppReport() {
				await queryThreeBuildFourFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryThreeBuildFiveFloorSafeByAppReport() {
				await queryThreeBuildFiveFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async querytwoBuildOneFloorSafeByAppReport() {
				await querytwoBuildOneFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async querytwoBuildTwoFloorSafeByAppReport() {
				await querytwoBuildTwoFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async querytwoBuildThreeFloorSafeByAppReport() {
				await querytwoBuildThreeFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async querytwoBuildFourFloorSafeByAppReport() {
				await querytwoBuildFourFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async querytwoBuildFiveFloorSafeByAppReport() {
				await querytwoBuildFiveFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryoneBuildOneFloorSafeByAppReport() {
				await queryoneBuildOneFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryoneBuildTwoFloorSafeByAppReport() {
				await queryoneBuildTwoFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryoneBuildThreeFloorSafeByAppReport() {
				await queryoneBuildThreeFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryoneBuildFourFloorSafeByAppReport() {
				await queryoneBuildFourFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryoneBuildFiveFloorSafeByAppReport() {
				await queryoneBuildFiveFloorSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryOneFloorOneSafeByAppReport() {
				await queryOneFloorOneSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryTwoFloorOneSafeByAppReport() {
				await queryTwoFloorOneSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryThreeFloorOneSafeByAppReport() {
				await queryThreeFloorOneSafeByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			goPage(url) {
				uni.navigateTo({
					url
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	page {
		background-color: #f5f5f5;
	}

	.messagePage {
		height: calc(100vh - var(--window-top));
		width: 100%;

		.content {
			display: flex;
			flex-direction: column;
			height: calc(100% - 20rpx);
			font-family: Source Han Sans CN, Source Han Sans CN-400;

			.content_item {
				background: #ffffff;
				border-radius: 8px;
				box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);
				font-family: "黑体", "Heiti SC", "STHeiti", sans-serif;

				.line {
					width: 12rpx;
					height: 32rpx;
					background: #3276FF;
					border-radius: 3px;
				}

				.itemName {
					font-size: 32upx;
					color: #333333;
					font-weight: 600;
				}


				.rowName {
					font-size: 28upx;
					color: #333333;
				}

				.rowValue {
					font-size: 28upx;
					color: #666666;
				}

				.font_red {
					color: #E14B4B;
				}
			}

			.my_flex_sb:last-child {
				margin-bottom: 0 !important;
			}
		}
	}
</style>